package com.utils;

public class PageUtil {
	public static PageInfo getPageInfo(int pageSize, int rowCount, int pageIndex) {
		PageInfo pageInfo = new PageInfo();
		pageInfo.setPageSize(pageSize == 0 ? 10 : pageSize);
		pageInfo.setRowCount(rowCount);
		pageInfo.setPageIndex(pageIndex);
		pageInfo.setPageCount((pageInfo.getRowCount() + pageInfo.getPageSize() - 1) / pageInfo.getPageSize());
		pageInfo.setBeginRow(pageInfo.getPageSize() * (pageInfo.getPageIndex() - 1));
		pageInfo.setHasNext(pageInfo.getPageIndex()<pageInfo.getPageCount());
		pageInfo.setHasPre(!(pageIndex==1));
		return pageInfo;
	}
}
